<template>
	<view>
		<image class="bg1" src="@/static/img/bg1.png"></image>
		<view class="header-box">
			<u-row @click="gotoProfile">
							   <u-col span="4">
			       <u-avatar size="60" :src="'http://localhost:8080/'+vuex_user.avatar"></u-avatar>
			      </u-col>
			       <u-col span="6">
			
									 <view v-if="!vuex_token" class="no-login" @click="login">未登录</view>
									 <view v-else class="user-info">
											<view class="user-name">
												{{vuex_user.nickname}}
											</view>
											<view class="">
												{{vuex_user.mobile}}
											</view>
									 </view>
			       </u-col>
			  </u-row>
		</view>
			 <view class="menu-box">
				 <u-cell-group>
								<u-cell icon="/static/img/ico_actives.png" @click="toPage('/pages/user/myactive')" isLink title="我参与的活动"></u-cell>
				                <u-cell icon="/static/img/ico_verification.png" @click="toPage('/pages/user/manageactive')" isLink title="我管理的活动"></u-cell>
				                <u-cell icon="/static/img/ico_profile.png"  @click="toPage('/pages/user/profile')" isLink title="个人资料"></u-cell>
				                <u-cell icon="/static/img/ico_help.png" @click="toPage('/pages/public/page',{id:1})" isLink title="使用帮助"></u-cell>
				                <u-cell icon="/static/img/ico_rule.png" @click="toPage('/pages/public/page',{id:2})" isLink title="活动报名规则"></u-cell>
				                <u-cell icon="/static/img/ico_about.png" @click="toPage('/pages/public/page',{id:3})" isLink title="关于我们"></u-cell>
								<u-cell icon="/static/img/ico_logout.png" isLink title="退出" rightIcon="arrow-right" @click="logout"></u-cell>
				 </u-cell-group>
			 </view>
			
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			login(){
				uni.$u.route('/pages/public/login');
			},
			logout(){
				this.$u.vuex('vuex_token', '');
				this.$u.vuex('vuex_user', {});
				try{
					uni.setStorageSync('lifeData','')
				}catch(e){
					//TODO handle the exception
				}
				uni.$u.toast("退出成功")
				// setTimeout(()=>{
				// 	uni.switchTab({
				// 		url:'/pages/index/index'
				// 	})
				// },1000)
			},
			gotoProfile(){
				if(this.vuex_token){
					uni.$u.route('/pages/user/profile');
				}
				
			}
		}
	}
</script>

<style lang="scss">
.bg1{
	width: 310rpx;
	height: 416rpx;
	position: absolute;
	left: 0;
	top: -80px;
	z-index: 1;
}
.header-box{
	padding: 50px 40px 10px 40px;
	.user-info{
		color: #666666;
		.user-name{
			font-size: 18px;
			font-weight: 600;
			color: #333333;
		}
	}
}
.menu-box{
	padding: 40px 10px 20px 10px;
}
</style>
